import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.Buffer;

public class ServerDemo001 {

	public static void main(String[] args) {

		try {
			ServerSocket server = new ServerSocket(9999);
			Socket s = server.accept();
			OutputStream out = s.getOutputStream();

			InputStream in = s.getInputStream();
			BufferedReader br = new BufferedReader(new InputStreamReader(in));
			String str = br.readLine();
			System.out.println(str);

			out.write("hello".getBytes());
			br.close();
			in.close();

			out.close();
			s.close();

			System.out.println("hahahahhahaahahhahaah");

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}
